<script setup lang="ts">
import { deleteErrorTrain } from "../../api/train"

const fs = window.require("fs")
const path = window.require("node:path")
import { onMounted } from "vue"

function deleteAllFilesInFolder(folderPath: string) {
  fs.readdir(folderPath, (err, files) => {
    if (err) {
      console.error("Error reading folder:", err)
      return
    }
    for (const file of files) {
      const filePath = path.join(folderPath, file)
      fs.unlink(filePath, err => {
        if (err) {
          console.error("Error deleting file:", err)
        }
      })
    }
  })
}

onMounted(() => {
  /// 清理视频缓存
  const Path = path.join(window.electron.ipcRenderer.sendSync("path"), "../..", "video")
  deleteAllFilesInFolder(Path)
  getErrorTrain()
})

function getErrorTrain() {
  // deleteErrorTrain()
}
</script>

<template>
  <div class="home">
    <div class="top">
      <router-link to="/Train">
        <div>培训</div>
      </router-link>
      <div>会议</div>
      <div>
        <router-link to="/ReportForms">
          <div>报表</div>
        </router-link>
      </div>
    </div>
    <div class="bottom">
      <div>文件库</div>
      <router-link to="/employee">
        <div>员工展板</div>
      </router-link>
      <router-link to="/risk">
        <div>风险库</div>
      </router-link>
    </div>
  </div>
</template>

<style>
.home {
  width: 100%;
  height: 100%;
  background-image: url("../../assets/image/main/MainBg.jpg");
  background-size: 100% 100%;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  align-items: center;
}

.top {
  width: 100%;
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.bottom {
  width: 100%;
  display: flex;
  justify-content: space-around;
  align-items: center;
}

.top div,
.bottom div {
  width: 100px;
  height: 100px;
  border-radius: 100px;
  font-size: 20px;
  font-weight: bold;
  color: #fff;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}
</style>
